from django.db import models
from user.models import User, Merchants


# Create your models here.
# 地址表
class Address(models.Model):
    CHOICES = (
        (0, '男'),
        (1, '女'),
    )
    name = models.CharField(max_length=32, verbose_name='收货人名字')
    phone = models.CharField(max_length=11, verbose_name='收货人手机')
    gender = models.IntegerField(default=0, choices=CHOICES, verbose_name='性别')
    address = models.CharField(max_length=128, verbose_name='收货地址')
    address_detailed = models.CharField(max_length=128, verbose_name='收货具体地址')
    title = models.CharField(max_length=16, default="", verbose_name='收货人名字')
    longitude = models.DecimalField(max_digits=10, decimal_places=6, verbose_name='经度')
    latitude = models.DecimalField(max_digits=10, decimal_places=6, verbose_name='纬度')
    user_id = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name='用户id')
    shop_id = models.ForeignKey(Merchants, on_delete=models.CASCADE, verbose_name='商家id')

    class Meta:
        db_table = 'address'
        verbose_name_plural = '地址'

    def __str__(self):
        return self.name